package org.lisa.crm.controller.marketing;

import org.lisa.crm.common.util.Result;
import org.lisa.crm.framework.context.BaseController;
import org.lisa.crm.model.CusDevPlan;
import org.lisa.crm.model.SaleChance;
import org.lisa.crm.service.CusDevPlanService;
import org.lisa.crm.service.MarketingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by admin on 2018/1/29.
 */
@Controller
@RequestMapping("/cus_dev_plan")
public class DevCustomerPlanController extends BaseController{

    @Autowired
    private MarketingService service;

    @Autowired
    private CusDevPlanService cusDevPlanService;

    @RequestMapping("/index.html")
    public ModelAndView index(int sid){

        ModelAndView mv = new ModelAndView();
        mv.setViewName("cus_dev_plan_detail");

        SaleChance saleChance = service.querySalesChangeById(sid);
        mv.addObject("saleChance",saleChance);
        return mv;

    }

    @RequestMapping("/insert")
    @ResponseBody
    public Result saveCusDevPlan(CusDevPlan cusDevPlan){

        return cusDevPlanService.insertCusDevPlan(cusDevPlan);

    }


    ///cus_dev_plan/queryCusDevPlansByParams?saleChanceId
    @RequestMapping("/queryCusDevPlansByParams")
    @ResponseBody
    public Map<String,Object> queryCusDevPlansByParams(CusDevPlan cusDevPlan){

        return cusDevPlanService.queryCusDevPlansByParams(cusDevPlan);

    }

    //delete
    @RequestMapping("/delete")
    @ResponseBody
    public Result deleteCusDevPlan(CusDevPlan cusDevPlan){

        return cusDevPlanService.deleteCusDevPlan(cusDevPlan);

    }

}
